﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Box.Entities;

namespace Box.Repository.Mapping
{
    public class DetalleKitMap:EntityTypeConfiguration<DetallKits>
    {
        public DetalleKitMap()
        {
            this.HasKey(p => new { p.Item,p.IdKit});
            this.Property(p => p.Item)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(p => p.Cantidad)
                .IsRequired();

            this.Property(p => p.PrecioUnit)
                .HasPrecision(9, 2);
            
            this.Ignore(p => p.Monto);

            this.ToTable("DETALLEKIT");
            this.Property(p => p.Item).HasColumnName("Item");
            this.Property(p => p.Cantidad).HasColumnName("Cantidad");
            this.Property(p => p.PrecioUnit).HasColumnName("PrecioUnit");

            this.HasRequired(p=>p.Producto)
                .WithMany()
                .HasForeignKey(p=>p.IdProducto)
                .WillCascadeOnDelete(false);


        }
    }
}
